export default class Camera {
  constructor(viewer) {
    this.viewer = viewer;
    this.camera = viewer.camera;
  }

  //相机位置
  flyTo(destination) {
    this.camera.flyTo({
      destination: destination,
      orientation: {
        heading: Cesium.Math.toRadians(20.0), // 方向
        pitch: Cesium.Math.toRadians(-90.0), // 倾斜角度
        roll: 0
      },
      pitchAdjustHeight: -90, // 如果摄像机飞越高于该值，则调整俯仰俯仰的俯仰角度，并将地球保持在视口中。
      maximumHeight: 5000, // 相机最大飞行高度
      flyOverLongitude: 100, // 如果到达目的地有2种方式，设置具体值后会强制选择方向飞过这个经度
    })
  }
  flyTo2(destination) {
    this.camera.flyTo({
      destination: destination,
      orientation: {
        heading: Cesium.Math.toRadians(360.00), // 方向
        pitch: Cesium.Math.toRadians(-90.00), // 倾斜角度
        roll: Cesium.Math.toRadians(0.00)
      }
    });
  }
  toView(destination, orientation) {
    this.camera.setView({
      destination: destination,
      orientation: orientation == undefined ? {
        heading: Cesium.Math.toRadians(360.00), // 方向
        pitch: Cesium.Math.toRadians(-90.00), // 倾斜角度
        roll: Cesium.Math.toRadians(0.00)
      } : orientation
    });
  }
  //视图切换
  topView(entity) {
    this.viewer.trackedEntity = undefined;
    this.viewer.zoomTo(entity, new Cesium.HeadingPitchRange(0, Cesium.Math.toRadians(-90)));
  }
  //视图切换
  sideView(entity) {
    this.viewer.trackedEntity = undefined;
    this.viewer.zoomTo(entity, new Cesium.HeadingPitchRange(Cesium.Math.toRadians(-90), Cesium.Math.toRadians(-15), 10000));
  }
  //视图切换
  aircraftView(entity) {
    this.viewer.trackedEntity = entity;
  }
  //定位到要素
  zoomTo(data) {
    this.viewer.zoomTo(data, new Cesium.HeadingPitchRange(0.5, -0.2, data.boundingSphere.radius * 1.0));
  }
  //toHome
  toHome() {
    this.viewer.trackedEntity = undefined;
    this.camera.setView({
      destination: Cesium.Cartesian3.fromDegrees(118.804722, 31.976727, 500000)
    });
  }
}